def eliminateDuplicates(numbers): # DO NOT modify this line 
    list3=[]
    for i in numbers :
        if i not in list3:
            list3.append(i)
    return list3
# === DO NOT modify the code below ===
def main():
    list1 = [ eval(x) for x in input().split() ]
    list2 = eliminateDuplicates(list1)
    print(" ".join(map(str,list1)))
    print(" ".join(map(str,list2)))
    
if __name__ == "__main__":
    main()
# === DO NOT modify the code above ===